package com.itheima.test2;

import com.itheima.test2.domain.Person;


import java.util.ArrayList;
import java.util.Scanner;

public class Entry {
    public static void main(String[] args) {
        System.out.println("----------欢迎进入----------");
        ArrayList<Person> listStudent = new ArrayList<>();
        ArrayList<Person> listTeacher = new ArrayList<>();
        Operator op = new Operator();
        Scanner sc = new Scanner(System.in);
        while (true) {
            System.out.println("1:教师管理系统\t2学生管理系统\t3:退出");
            String select = sc.next();
            switch (select) {
                case "1":
                    loop:
                    while (true) {
                        //System.out.println("进入教师管理系统");
                        System.out.println("1:添加老师\t2删除老师\t3修改老师\t4查询老师\t5返回上一层\t0退出");
                        System.out.println("请输入选项:");
                        String select2 = sc.next();
                        switch (select2) {
                            case "1":
                                //添加
                                op.addPerson(listTeacher);
                                break;
                            case "2":
                                //删除
                                op.removePerson(listTeacher);
                                break;
                            case "3":
                                //修改
                                op.updatePerson(listTeacher);
                                break;
                            case "4":
                                //查询
                                op.queryAll(listTeacher);
                                break;
                            case "5":
                                //返回上层
                                break loop;
                            case "0":
                                //退出
                                return;
                            default:
                                System.out.println(" 输入错误 ");
                                break;
                        }
                    }
                    break;

                case "2":
//                    System.out.println("进入学生管理系统");
                    loop:
                    while (true) {
                        System.out.println("1:添加学生\t2删除学生\t3修改学生\t4查询学生\t5返回上一层\t0退出");
                        System.out.println("请输入选项:");
                        String select2 = sc.next();
                        switch (select2) {
                            case "1":
                                //添加
                                op.addPerson(listStudent);
                                break;
                            case "2":
                                //删除
                                op.removePerson(listStudent);
                                break;
                            case "3":
                                //修改
                                op.updatePerson(listStudent);
                                break;
                            case "4":
                                //查询
                                op.queryAll(listStudent);
                                break;
                            case "5":
                                //返回上层
                                break loop;
                            case "0":
                                //退出
                                return;
                            default:
                                System.out.println(" 输入错误 ");
                                break;
                        }
                    }
                    break;

                case "3":
                    System.out.println("谢谢使用,再见");
                    return;
                default:
                    System.out.println("输入有误");
            }

        }
    }
}
